package com.example.utility.crypto.rsa;

/**
 * @author 季舟
 * @Date 2025-02-26 9:58
 */
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;

public class RsaExampleHt {
    public static void main(String[] args) {
        String publicKey="MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAImLahmAkdg9SJng53ldeCTBJDsb14U9b0cOhghiiDBTDAvWFZvvQ6vh3v1XzaKGE01WxCSKRn2CUNOv/MerCQMCAwEAAQ==";
        String privateKey="MIIBOQIBAAJBAImLahmAkdg9SJng53ldeCTBJDsb14U9b0cOhghiiDBTDAvWFZvvQ6vh3v1XzaKGE01WxCSKRn2CUNOv/MerCQMCAwEAAQJAElYsueOjDeH1qNYL5ekpGDVLgDnQ/KlZCW8NPVbtcwua2aftmrxLxVUcoqxFBMQ6MPR0zJuu1RwHfJe8jCgRiQIhAP8V4HpYczwkXR+qWhhse9a57xFMkRjIceiMTAM00/c/AiEAigmn7DsyAEYQdDQcZQsbd3b+ZjDyBCo91dDc3Yk2IT0CIFkP6FqPO1zKTYFa1y4j4nEsZh4iH58JjUvmgDu2XDO9AiA/HkExjLPFWkRFzlo5fcW2b6vN8I2JiAM0VMfZaNdehQIgJf2ulHGQwLGWRUDLR3WIP1VaBAC2Gm70wug8xWzKlsE=";
        // 生成RSA密钥对
        RSA rsa = new RSA(privateKey, publicKey);
        String abc="310110193408245058";
        String pencrypted = rsa.encryptBase64(abc, KeyType.PublicKey);
        System.out.println(pencrypted);
        String content="OrF8QlyEZcW4nScFuGgWnmlQeQzJSLeYbqzilCsc4wauoZA4DkjMJWcCJZzHzWdue+G1fuHz/X+F+B22BxyxDw==";
        String encrypted = rsa.decryptStr(content, KeyType.PrivateKey);
        System.out.println(encrypted);
    }
}
